<?php
include("../db_connect.php");
?>
<script>
$(document).ready(function (){
$("#traderdata").html(loader).load("profile/traderdata.php");

$("#traderstatus").change(function () {
var status = $(this).val();

	$("#traderdata").html(loader).load("profile/traderdata.php?status="+status);

});

$("#tradedelete").click(function(){
	
	var tradearray = new Array();
	$("#traderdata tr td").find("input:checked").each(function(e){
			tradearray[e] = $(this).val();
		});
	
		if (tradearray.length <=0){
			$("#msgbox").empty().html("no row selected");
				$("#msgbox").dialog({
					modal:true,
					title:"Error",
					width:350,
					height: 200,
					show: "fade",
					hide: "fade",
					buttons: {
						OK: function() {
							$( this ).dialog( "close" );
						}

					},
				});
				
				

		}
		else if(tradearray.length >=1){
		
		
		$("#msgbox").empty().html("Delete?");
			$("#msgbox").dialog({
				modal:true,
				width:350,
				height: 200,
				show:"fade",
				hide: "fade",
				buttons: {
					OK: function() {
						$( this ).dialog( "close" );
						tradedelete(tradearray);
					},
					CANCEL: function() {
						$( this ).dialog( "close" );
					}
				},

			});
			

		}

});//

function tradedelete(tradearray){
		var type = "delete";
		$.ajax({
			url:"admin/traderdelete.php?id="+tradearray,
			success:function(data){
				$("#msgbox").html("You Successfully Delete a Trade");
				$("#msgbox").dialog({
					modal:true,
					title:"",
					width:350,
					height: 200,
					show: "fade",
					hide: "fade",
					buttons: {
						OK: function() {
							$( this ).dialog( "close" );
							location.reload();
								
						}

					},
				});
			}
		});
			
		
}





});//end of document




checked = false;
function checkalltrade(){
	if (checked == false){
		checked = true
	}
	else{
	checked = false
	}
	for (var i = 0; i < document.getElementById('mytraderequest').elements.length; i++){
		document.getElementById('mytraderequest').elements[i].checked = checked;
	}	
}


</script>

<div id="searchbox">
<!--search div-->
<div>
	<div class="headersearch ">
		<button id="tradedelete" name="out">Delete</button>
		<label>Status:</label>
		<select id="traderstatus">
			<option value="">All</option>
			<option value="Confirm">Confirm</option>
			<option value="Decline">Decline</option>
			<option value="Pending">Pending</option>
		</select>
		
	</div>
</div>			
		
<!--end search div-->		
</div>

<div id="traderdata" class="itemRequest2" style="overflow:auto">
	<?php //include("itemRequest.php"); ?>
</div>